package hd.util.file;

import org.apache.http.Header;
import org.apache.http.protocol.HTTP;

import java.io.InputStream;
import java.util.List;
import java.util.Map;
import java.util.Set;

import hd.util.load.FileLoader;


/**
 * 请求的文件信息
 * <p/>
 * Created by apple on 14/11/5.
 */
public class FileInfo {
    private InputStream inputStream;//输入流
    private Map<String, List<String>> header;//文件头信息

    /**
     * 设置文件输入流
     *
     * @param inputStream stream
     */
    public void setInputStream(InputStream inputStream) {
        this.inputStream = inputStream;
    }

    /**
     * 获取文件输出流
     *
     * @return inputStream
     */
    public InputStream getInputStream() {
        return inputStream;
    }

    /**
     * 设置文件头信息
     *
     * @param header 文件头
     */
    public void setHeader(Map<String, List<String>> header) {
        this.header = header;
    }

    /**
     * 获取文件头
     *
     * @return 文件头
     */
    public Map<String, List<String>> getHeader() {
        return header;
    }

    /**
     * 获取文件大小
     *
     * @return file size
     */
    public long getFileSize() {
        long size = 0;
        if (header == null)
            return -1;
        if (header.containsKey(HTTP.CONTENT_LEN))
            size = Long.parseLong(header.get(HTTP.CONTENT_LEN).get(0));
        return size;
    }
}